<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<h2>사용자 목록</h2>

<form method="get" action="" class="searchForm" id="usersFormDiv" onsubmit="return pageList.submit(); return false;">
<table class="searchQueryTb tb_search">
	<tbody>
		<tr>
			<th>권한</th>
			<td>
				<select name="userRoleCd" title="권한" class="query">
					<option value="">전체</option>
				<c:forEach items="${roleList}" var="item">
					<option value="${item.code}" <c:if test="${pageParam.userRoleCd == item.code}">selected="selected"</c:if>>${item.name}</option>
				</c:forEach>
				</select>
			</td>
			<th>상태</th>
			<td>
				<select name="userStateCd" title="상태" class="query">
					<option value="">전체</option>
				<c:forEach items="${stateList}" var="item">
					<option value="${item.code}" <c:if test="${pageParam.userStateCd == item.code}">selected="selected"</c:if>>${item.name}</option>
				</c:forEach>
				</select>
			</td>
		</tr>
		<tr>
			<th>사용자</th>
			<td colspan="3">
				<input type="text" name="userNameText" title="사용자" value="${pageParam.userNameText}" class="query"/>
			</td>
		</tr>
		<tr>
			<td colspan="4" class="textR">
				<input type="hidden" name="pageNum" value="${pageParam.pageNum}"/>
				<input type="hidden" name="orderBy" value="${pageParam.orderBy}"/>
				<input type="hidden" name="logMsg" />
				<span class="button medium"><button type="submit">조회</button></span>
			</td>
		</tr>
	</tbody>
</table>

<div class="clearfix searchBtn">
	<div class="floatR">
		<span class="button medium"><button type="button" class="userEditForm">등록</button></span>
	</div>
</div>

<div class="clearfix btn5">
	<div class="floatL">
		<span class="pageDataTotal">총 <strong>${pageDataTotal}</strong> 건</span>
	</div>
	<div class="floatR">
		<select name="pageCut" class="ui-widget-content ui-corner-all" >
			<c:forEach begin="10" end="50" step="5" var="cutNum">
				<option value="${cutNum}" <c:if test="${pageParam.pageCut==cutNum}">selected="selected"</c:if>>${cutNum}</option>
			</c:forEach>
		</select>
	</div>
</div>

<c:set var="loopIndex" value="${pageParam.startNum}"/>
<c:if test="${loopIndex > 1}"><c:set var="loopIndex" value="${loopIndex-1}"/></c:if>

<table class="searchDataList tb_list">
	<thead>
		<tr>
			<th scope="row" >NO</th>
			<th scope="row" class="order" filed="user_name"><span>사용자명</span></th>
			<th scope="row" class="order" filed="user_id"><span>사용자 ID</span></th>
			<th scope="row" class="order" filed="user_role"><span>권한</span></th>
			<th scope="row" class="order" filed="user_state"><span>상태</span></th>
			<th scope="row" class="order" filed="created"><span>등록일</span></th>
			<th scope="row" class="order" filed="last_modified"><span>최근 수정일</span></th>
		</tr>
	</thead>
	<tbody binText="등록된 계정이 없습니다.">
		<c:choose>
			<c:when test="${!empty pagingList}">
				<c:forEach items="${pagingList}" var="item" varStatus="loop">
		            <tr>
		                <td class="textC"><span>${loopIndex+loop.count}</span></td>
		                <td><a class="userEditForm" userId="${item.userId}">${item.userName}</a></td>
		                <td>${item.userId}</td>
		                <td class="userRoleTxt">${item.userRoleTxt}</td>
		                <td class="userStateTxt">${item.userStateTxt}</td>
		                <td class="textC"><fmt:formatDate value="${item.created}" pattern="yyyy-MM-dd"/></td>
		                <td class="textC"><fmt:formatDate value="${item.lastModified}" pattern="yyyy-MM-dd"/></td>
		            </tr>
		        </c:forEach>
			</c:when>
			<c:otherwise>
				<tr>
					<td scope="col" colspan="7" class="bin">등록된 계정이 없습니다.</td>
				</tr>
			</c:otherwise>
		</c:choose>
	</tbody>
</table>

<c:import url="../layout/paginate.jsp"></c:import>

</form>
<script type="text/javascript" src="<c:url value='/res/js/content/pageList.js'/>"></script>
<script type="text/javascript" src="<c:url value='/res/js/content/user/form.js'/>"></script>

